package com.atguigu.study.controller;

import com.atguigu.study.entities.User;
import com.atguigu.study.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
@ControllerAdvice
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping(value = "/user/add")
    public boolean addUser(@RequestBody User user)
    {
        /*boolean b1=userService.addUser(user);
        System.out.println(b1);*/
        return userService.addUser(user);
    }

    //http://localhost:2404/user/226
    @GetMapping(value = "/user/{id}")
    public User getUserById(@PathVariable("id") Integer id)
    {
        /*User user = userService.getUserById(id);
        System.out.println(user);*/
        return userService.getUserById(id);
    }

}
